# 导入游戏模块
import pygame
# 导入游戏封装类
from game_class_init import GameInitClass
# 导入游戏时钟模块
from game_class_clock import GameClassClock
# 导入英雄模块
from game_class_hero import GameClassHero
# 导入背景模块
from game_class_background import GameClassBackground
# 导入监听事件包
from game_class_listen import GameClassListen

# 游戏初始化
game_init_class_object = GameInitClass()
game_init_class_object.game_page_init()
# 记录英雄位置
hero_object = GameClassHero()
hero_object.set_hero_rect(150, 300, 102, 126)
# 实例化背景对象
background_object = GameClassBackground()

# 设置时钟步调
clock_object = GameClassClock()
# 游戏循环
while True:
    clock_object.set_clock_tick(60)
    hero_object.hero_rect.x -= 1
    # 重新绘制背景，防止重影
    background_object.draw_background(game_init_class_object.screen, game_init_class_object.background)
    # 绘制英雄
    hero_object.set_hero_to_rect(game_init_class_object.screen, game_init_class_object.hero, (hero_object.hero_rect.x, hero_object.hero_rect.y))
    # 条件判断
    if hero_object.hero_rect.y <= 0 or hero_object.hero_rect.x <= 0:
        break

    # 获取监听事件
    GameClassListen(pygame.event.get())

